class SayController < ApplicationController
  def hello
  	@oauth = ConstantContact::Auth::OAuth2.new(
  :api_key => 'cuky27fwykbpaw4qa7cnwfng',
  :api_secret => 'NGBBcBzVKHsPzhqJd2GRHguJ',
  :redirect_url => 'http://test.apache.com/' # the URL given when registering your app with Mashery.
)

@error = params[:error]
@user = params[:username]
@code = params[:code]

if @code.present?
  response = @oauth.get_access_token(@code)
  if response.present?
    token = response['154d9dc4-4313-4d24-bd1b-6a1940738f24']
    cc = ConstantContact::Api.new('cuky27fwykbpaw4qa7cnwfng')
    @contacts = cc.get_contacts(token)
  end
else
  # if not code param is provided redirect into the OAuth flow
  redirect_to @oauth.get_authorization_url and return
end
  end

  def goodbye
  end
end
